<?php

namespace app\common\service;


class HostMinistry extends Base 
{

    /**
     * @name 列表
     * @return array|\PDOStatement|string|\think\Collection
     * @author wx
     * @date 2019/10/25 11:02
     */
    function list()
    {
        return db('host_ministry')->field('id, pid, name')->select();
    }

    /**
     * @name 查询
     * @param $condition
     * @return array|null|\PDOStatement|string|\think\Model
     * @author wx
     * @date 2019/10/25 11:24
     */
    function findData($condition)
    {
        return db('host_ministry')->where($condition)->find();
    }

    /**
     * @name 添加
     * @param $addData
     * @return int|string
     * @author wx
     * @date 2019/10/25 11:24
     */
    function add($addData)
    {
        return db('host_ministry')->insertGetId($addData);
    }

    /**
     * @name 修改
     * @param $condition
     * @param $updateData
     * @return int|string
     * @author wx
     * @date 2019/10/25 13:28
     */
    function modify($condition, $updateData)
    {
        return db('host_ministry')->where($condition)->update($updateData);
    }

    /**
     * @name 删除
     * @param $condition
     * @return int|string
     * @author wx
     * @date 2019/10/25 13:42
     */
    function del($condition)
    {
        return db('host_ministry')->where($condition)->delete();
    }


    /**
     * @name: 所属部门展示
     * @Param: ministryId_a  所属部门id数组
     * @Description: 
     * @Author: foo
     * @Date: 2019-03-27 10:07:57
     */
    function showMinistry ($ministryId_a = [], $field = '', $index = '')
    {
        $server = model('HostMinistry');

        empty($ministryId_a) ? : $server->whereIn('id', $ministryId_a);
        
        empty($field) ? : $server->field($field);

        $ministryData = empty($index) ? $server->select() : $server->column($field, $index);

        return $ministryData;

    }
}